﻿using System.Runtime.Serialization;
using System.Collections.Generic;
using System.Xml.Serialization;

namespace ScrumFactory {

    [DataContract]
    public class Sprint {

        
        private System.DateTime endDate;

        [DataMember]
        public string SprintUId { get; set; }

        [DataMember]
        public string ProjectUId { get; set; }

        [DataMember]
        public int SprintNumber { get; set; }

        [DataMember]
        public System.DateTime StartDate { get; set; }

        [DataMember]
        public System.DateTime EndDate {
            set {
                if (value < StartDate)
                    throw new System.Exception("Sprint end date should be after sprint start.");
                endDate = value;
            }
            get {
                return endDate;
            }
        }
        
        [XmlIgnore]
        public Project Project { get; set; }

     
        public bool IsOver {
            get {
                return System.DateTime.Today > EndDate;
            }
        }

        public int WorkDayCount {
            get {
                return Project.CalcWorkDayCount(StartDate, EndDate);
            }
        }

        public int WorkDaysLeft {
            get {
                return Project.CalcWorkDayCount(System.DateTime.Today, EndDate);
            }
        }

        
    }
}
